#!/usr/bin/expect
# 默认30s, 防止超时
set timeout -1

set user ksprod
set password [lindex $argv 0]
set ip 10.0.8.131
set path /opt/zoomeyebe/node_modules/zoomeyebe-ui
set folder build

spawn ssh ${user}@${ip} "rm -rf ${path}/${folder}"
expect {
    "yes/no" {
        send "yes\r";
        exp_continue
    }
    "password:" {
        send "$password\r"
    }
}

spawn scp -r build ${user}@${ip}:${path}
expect {
    "yes/no" {
        send "yes\r";
        exp_continue
    }
    "password:" {
        send "$password\r"
    }
} 

expect eof
